package com.example.clothingmanager.dao;

import com.example.clothingmanager.bean.Clothes;
import com.example.clothingmanager.bean.Instock;
import com.example.clothingmanager.bean.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author Huangyt
 * @version 1.0
 * @date 2020/5/9 15:53
 */
public interface InstockDao extends JpaRepository<Instock, String> {

    @Query(value = "select * from tb_instock where depotid =:depotid", nativeQuery = true, countQuery = "select count(1) from tb_instock")
    public Page<Instock> findByDepot(int depotid, Pageable pageable);

    @Query(value = "select distinct(stockname) from tb_instock", nativeQuery = true)
    public List<String> getStocknames();

    @Query(value = "select sum(num) from tb_instock where citem=:citem group by citem", nativeQuery = true)
    public Integer countByClothes(String citem);

}
